#ifndef __IMATERIAL_H__
#define __IMATERIAL_H__

#include "../include/ITexture.h"
#include "../include/ITextureCoordinates.h"

class IMaterial
{
protected:
	CColor Ambient;
	CColor Specular;
	CColor Difuse;
	f32 Shiness;
	ITexture *Texture;
public:
    IMaterial()
    {
        SetDefault();
    }

//	IMaterial(IMaterial &other):Ambient(other.Ambient),Specular(other.Specular),Difuse(other.Difuse),Shiness(other.Shiness),Texture(other.Texture)	{}

	IMaterial(IMaterial *other)
	{
		if (other)
		{
			Ambient = other->Ambient;
			Specular = other->Specular;
			Difuse = other->Difuse;
			Shiness = other->Shiness;
			Texture = other->Texture;
		}
		else
		{
		    SetDefault();
		}
	}

	IMaterial(CColor newAmbient,
		CColor newSpecular =CColor(1.0,1.0,1.0),
		CColor newDifuse=CColor(1.0,1.0,1.0),
		ITexture *newTexture=NULL
		):Ambient(newAmbient),Specular(newSpecular),Difuse(newDifuse),Texture(newTexture),Shiness(1.0) {}

	virtual ~IMaterial()
	{
//		DEALLOCATE(Texture);
	}

    virtual void SetDefault()
    {
		Ambient.SetRGBA(1.0,1.0,1.0,1.0);
		Specular.SetRGBA(1.0,1.0,1.0,1.0);
		Difuse.SetRGBA(1.0,1.0,1.0,1.0);
		Shiness = 1.0;
		Texture = NULL;
    }

	virtual IMaterial &operator=(IMaterial &other)
	{
		Ambient = other.Ambient;
		Specular = other.Specular;
		Difuse = other.Difuse;
		Texture = other.Texture;
		Shiness = 1.0;
		return *this;
	}

	inline void SetAmbient(CColor &newAmbient)										{	Ambient = newAmbient;						}
	inline void SetSpecular(CColor &newSpecular)									{	Specular = newSpecular;						}
	inline void SetDifuse(CColor &newDifuse)										{	Difuse = newDifuse;							}
	inline void SetShiness(vPos ns)													{	Shiness = ns;								}
	inline CColor &GetAmbient()														{	return Ambient;								}
	inline CColor &GetSpecular()													{	return Specular;							}
	inline CColor &GetDifuse()														{	return Difuse;								}
	inline f32 GetShiness()															{	return Shiness;								}
	inline f32 *GetAmbientVector()													{	return Ambient.GetColorVector();			}
	inline f32 *GetDifuseVector()													{	return Difuse.GetColorVector();				}
	inline f32 *GetSpecularVector()													{	return Specular.GetColorVector();			}
	inline void SetTexture(ITexture *newTexture)									{	Texture = newTexture;						}
	inline ITexture *GetTexture()													{	return Texture;								}
};

#endif
